package ge.telasi.tasks.model.validation;

import ge.telasi.tasks.EJBLocaleManager;
import ge.telasi.tasks.LocaleManager;
import ge.telasi.tasks.TaskException;
import javax.persistence.EntityManager;

/**
 * @author dimitri
 */
public abstract class Validator {
    private LocaleManager lm = new EJBLocaleManager();
    private EntityManager em;

    public LocaleManager getLocaleManager() {
        return lm;
    }

    public Validator() {
        this(null);
    }

    public Validator(EntityManager em) {
        this.em = em;
    }

    protected void requireEM() {
        if (em == null) {
            throw new TaskException("EM required.");
        }
    }

    protected EntityManager getEm() {
        return em;
    }
}
